Object.defineProperty(exports, "__esModule", {
  value: true
});
var AudioManager = require("AA_AudioManager");
var _def_UIBindings = function () {
  function _creator() {
    this._btnNames = [];
    this._buttons = [];
    this._clickFastMap = new Map();
    this._clickInterval = 500;
    this._clickTimeMap = new Map();
  }
  _creator.prototype.addClickListener = function (e, t) {
    var o = this;
    this._callfunc = e;
    this._target = t;
    this._buttons = [];
    this._btnNames.forEach(function (e) {
      var t = o[e];
      t && t instanceof cc.Button && o._buttons.push(o[e]);
    });
    for (var n = 0; n < this._buttons.length; n++) {
      var i = this._buttons[n];
      i && this._addClickListener(i);
    }
  };
  _creator.prototype.setClickFast = function (e) {
    this._buttons.includes(e) && this._clickFastMap.set(e, true);
  };
  _creator.prototype._addClickListener = function (e) {
    var t = e.node;
    t.targetOff(this);
    t.on("click", this._clickListener, this);
    t.on(cc.Node.EventType.TOUCH_START, function () {
      AudioManager.AudioMgr.playEffect("audio/effect/button");
    }, this);
  };
  _creator.prototype._clickListener = function (e) {
    var t = this._clickTimeMap.get(e);
    var o = new Date().getTime();
    var n = 0;
    this._clickFastMap.has(e) || (n = this._clickInterval);
    if (!t || o - t >= n) {
      this._clickTimeMap.set(e, o);
      this._callfunc.apply(this._target, [e]);
    }
  };
  return _creator;
}();
exports.default = _def_UIBindings;